package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description
 * User:华为
 * Date:2024/10/18
 * Time:21:12
 */
public class ReturnOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你想要归还书的书名");
        String name = scanner.nextLine();
        int currentsize = bookList.getUsedSize();
        for (int i = 0; i < currentsize; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)){
                book.setBorrowed(false);
                System.out.println("已经成功归还");
                return;
            }
        }
        System.out.println("未找到想归还的书");

    }
}
